package org.hit.burkun.cases.pipline;

import org.hit.burkun.db.DBHelper;
import org.hit.burkun.db.DBTypeConverter;
import org.hit.burkun.dbimport.FileBaseImport;
import org.hit.burkun.file.FileProcessHelper.FILE_TYPE;
import org.hit.burkun.util.GlobalData;

public class OMIMImport extends FileBaseImport {

	public OMIMImport(String fullFileName, FILE_TYPE fileType,
			String tableName, DBHelper dbHelper, int totalPropertyNum,
			boolean hasAutoIncreasementID, DBTypeConverter typeConverter,
			LINE_SPLITER spliterType) {
		super(fullFileName, fileType, tableName, dbHelper, totalPropertyNum,
				hasAutoIncreasementID, typeConverter, spliterType);
	}

	public static void importOmim2gene() {
		String fileName = GlobalData.getInstance().getOmim2GenePath();
		final DBHelper dbHelper = DBHelper.getLocalBioSearch();
		int totalPropertyNum = 5;
		FILE_TYPE fileType = FILE_TYPE.PLAIN;
		String tableName = "omim_mim2gene";
		int beginLine = 2;
		boolean hasAutoIncreasementID = false;
		LINE_SPLITER spliterType = LINE_SPLITER.TAB;

		DBTypeConverter.DATATYPE[] types = new DBTypeConverter.DATATYPE[totalPropertyNum];
		types[0] = DBTypeConverter.DATATYPE.I;

		DBTypeConverter typeConverter = new DBTypeConverter(types);
		FileBaseImport imp = new OMIMImport(fileName, fileType, tableName,
				dbHelper, totalPropertyNum, hasAutoIncreasementID,
				typeConverter, spliterType);

		imp.doImport(beginLine);
	}

	@Override
	public String[] forEachItem(String[] item) {
		for (int i = 0; i < item.length; i++) {
			if (item[i].equals("-")) {
				item[i] = "";
			}
		}
		return item;
	}

}
